package mapper;

import BO.QuestionNumberBO;
import DO.ChooseQuestionDO;
import DTO.PageChooseQuestionDTO;
import DTO.UpdateChooseQuestionDTO;
import VO.ChooseQuestionVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ChooseQuestionMapper {


    /**
     * 分页查询 ，第一步，查总数
     * @param pageChooseQuestionDTO
     * @return
     */
    Integer getTotal(PageChooseQuestionDTO pageChooseQuestionDTO);

    List<ChooseQuestionVO> page(PageChooseQuestionDTO pageChooseQuestionDTO);

    // 获取所有的编号
    @Select("select question_number from choose_question")
    List<String> getQuestionNumber();

    // 添加学生
    void addChoose(ChooseQuestionDO chooseQuestionDO);

    // 获取该试题的答案
    @Select("select answer from choose_question where id = #{id}")
    String getAnswerById(Integer id);

    // 更改选择题
    void updateChoose(UpdateChooseQuestionDTO updateChooseQuestionDTO);

    // 删除选择题
    @Delete("delete from choose_question where id = #{id}")
    void deleteById(Integer id);

    // 获取所有编号和id
    @Select("select id,question_number from choose_question where chapter>= #{startRange} and chapter<= #{endRange} order by question_number")
    List<QuestionNumberBO> getQuestionNumberAndId(Integer startRange,Integer endRange);

    // 根据id 获取所有数据
    @Select("select * from choose_question where id = #{id}")
    ChooseQuestionDO getById(Integer id);
}
